def main():
    with open('input_410.txt', 'r') as file:
        lines = file.readlines()
        n, k = map(int, lines[0].split())
        points = list(map(int, lines[1].split()))
    
    points.sort()

    if n == 0:
        with open('output_410.txt', 'w') as output_file:
            output_file.write("0\n")
        return

    res = 0
    i = 0
    while i < n:
        left = points[i]
        right = left + k
        res += 1
        while i < n and points[i] <= right:
            right = max(right, points[i] + k)
            i += 1
        if i < n and points[i] > right:
            res = -1
            break

    with open('output_410.txt', 'w') as output_file:
        output_file.write(f"{res}\n")


if __name__ == "__main__":
    main()
